package com.aspose.cells.b.a.d;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class zi extends zm {
   private InputStream a;
   private long b = -1L;
   private int c = 0;

   public zi(InputStream var1) {
      this.a = var1;
   }

   public zi(InputStream var1, long var2) {
      this.a = var1;
      this.b = var2;
   }

   public InputStream g() throws Exception {
      return this.a;
   }

   public OutputStream j() throws Exception {
      return null;
   }

   public boolean d() {
      return true;
   }

   public boolean e() {
      return false;
   }

   public boolean f() {
      return false;
   }

   public boolean k() {
      return false;
   }

   public long h() throws IOException {
      if (this.b > -1L) {
         return this.b;
      } else if (!this.a.markSupported()) {
         throw new UnsupportedOperationException("getLength() is not supported for " + this.a.getClass().getName());
      } else {
         this.a.mark(Integer.MAX_VALUE);
         this.b = (long)this.c;
         long var1 = 0L;

         while(true) {
            var1 = this.a.skip(2147483647L);
            if (var1 <= 0L) {
               this.a.reset();
               return this.b;
            }

            this.b += var1;
         }
      }
   }

   public long i() throws IOException {
      return (long)this.c;
   }

   public void b(long var1) throws IOException {
      if (var1 > (long)this.c) {
         for(long var3 = 0L; (long)this.c < var1; this.c = (int)((long)this.c + var3)) {
            var3 = this.a.skip(var1 - (long)this.c);
            if (var3 <= 0L) {
               throw new IOException("End of stream reached.");
            }
         }
      } else if (var1 == (long)this.c) {
         return;
      }

      throw new UnsupportedOperationException("Cannot access common java.io.InputStream backward.");
   }

   public long a(long var1, int var3) throws IOException {
      switch(var3) {
      case 0:
         this.b(var1);
         break;
      case 1:
         this.b((long)this.c + var1);
         break;
      case 2:
         this.b(this.h() + var1);
      }

      return (long)this.c;
   }

   public void b() throws IOException {
      throw new UnsupportedOperationException("flush() is not supported for common java.io.InputStream.");
   }

   public void a() throws IOException {
      this.a.close();
   }

   public void a(long var1) throws IOException {
      throw new UnsupportedOperationException("setLength() is not supported for common java.io.InputStream.");
   }

   public int a(byte[] var1, int var2, int var3) throws IOException {
      int var4;
      int var5;
      for(var4 = 0; var4 < var3; var2 += var5) {
         var5 = this.a.read(var1, var2, var3 - var4);
         if (var5 <= 0) {
            break;
         }

         var4 += var5;
      }

      this.c += var4;
      return var4;
   }

   public void b(byte[] var1, int var2, int var3) throws IOException {
      throw new UnsupportedOperationException("write() is not supported for common java.io.InputStream.");
   }
}
